<?php

namespace App\Http\Controllers;

use App\Facades\Data;
use App\Helpers\SystemHelper;
use App\Services\DfService;
use App\Services\WsService;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Str;

class CustomerController extends Controller
{
    private $dfService;
    private $wsService;

    function __construct(DfService $dfService,WsService $wsService)
    {
        $this->dfService=$dfService;
        $this->wsService=$wsService;
    }

    public function customerInfo(Request $request){
        $external_userid=$request->input('external_userid','');
        $userid=$request->input('userid','');
        if($external_userid==='' && $userid!==''){
            Data::set(SystemHelper::PARAM_ERROR,SystemHelper::PARAM_ERROR_MSG);
            return Data::returnMsg();
        }
        $mobile_str=$this->wsService->getMobile($external_userid,$userid);
        if($mobile_str==''){
            Data::setSuccess([]);
            return Data::returnData();
        }
        $rn=Str::random(16);
        $sign=$this->dfService->createSign($mobile_str,$rn);
        $this->dfService->getStuInfo($mobile_str,$rn,$sign);
        return Data::returnData();
    }
}
